home *** CD-ROM | disk | FTP | other *** search
- * $Filename: WormWars/Source/qdraw020.asm $
- * $VER: WormWars 6.1 (16.6.100) for Amiga
- *
- * © Copyright 2000 Jilles Tjoelker. Freely distributable.
- *
- * Worm Wars is © Copyright 2000 James R. Jacobs. Freely distributable.
- * _
- * // -=AMIGA=-
- * //
- * _ //
- * \\ //
- * \X/
- *
- * Assemble with PhxAss, see assemble.s.
- * Set ISO for isometric version, don't set it for normal version.
-
- machine 68020
-
- SQUAREX=9 ; <=16! ; <=32 can be done with a simple modification
- SQUAREY=6 ; <=16! ; but >32 is more difficult
-
- NPLANES=4 ; dynamic could be done easily
-
- AnPInfo equr a0
- AnDPtr equr a1
- AnPOffset equr a2
- AnPPtr equr a3
-
- DnX equr d0
- DnData equr d1
- DnHeight equr d2
- DnPlane equr d3
- DnBPR equr d4
- DnScratch1 equr d5
- DnPlaneSZ equr d6
-
- ; - don't change d0-d1/a0-a1
- ; - # of BPR < # of PlaneSZ (for MOVEM)
-
- regstosave reg d2-d6/a2-a3 ; all of the above, except d0-d1/a0-a1
-
- IFND ISO
- @qdraw020:
- xdef @qdraw020
- ENDC
-
- IFD ISO
- @qdraw020iso:
- xdef @qdraw020iso
- ENDC
-
- ; Prototype:
- ; void __asm qdraw020(register __a0 struct QDPlaneInfo *pi,register __d0 LONG x,register __d1 LONG y,register __a1 UWORD *data);
- ; or:
- ; void __regargs qdraw020(struct QDPlaneInfo *pi,LONG x,LONG y,WORD *data);
-
- ; The latter needs @qdraw020. (I've done that.)
-
- ; x&y are relative to screen bitmap, not window. Add window->TopEdge to y in C.
- ; The QDPlaneInfo contains information of the screen->RastPort.BitMap.
-
- rsreset
- pi_Planes rs.l NPLANES ; copy of bm_Planes[] element 0 to 3
- pi_BPR rs.l 1 ; bytesperrow
- pi_PlaneSZ rs.l 1 ; bytesperrow*rows
-
- ; struct QDPlaneInfo
- ; {
- ; UWORD *pi_Planes[4];
- ; ULONG pi_BPR,pi_PlaneSZ;
- ; };
-
- MOVEM.L regstosave,-(sp)
-
- MOVEM.L pi_BPR(AnPInfo),DnBPR/DnPlaneSZ ; # of BPR < # of PlaneSZ!
-
- MOVEQ #0,DnPlane
-
- *MOVE.L <y>,DnData ; already in there
- MULU.W DnBPR,DnData
- MOVEA.L DnData,AnPOffset
-
- .planeloop:
-
- MOVEA.L pi_Planes(AnPInfo,DnPlane.L*4),AnPPtr
- ADDA.L AnPOffset,AnPPtr
-
- IFND ISO
-
- MOVEQ #SQUAREY-1,DnHeight
-
- .yloop:
- MOVE.W (AnDPtr)+,DnData
- LSR.W #16-SQUAREX,DnData ; Image left-aligned <-> BFINS right-aligned
- BFINS DnData,(AnPPtr){DnX:SQUAREX}
-
- ADDA.L DnBPR,AnPPtr
- DBF DnHeight,.yloop
-
- ENDC ; ISO
-
- IFD ISO
-
- *For isometric: (a lot is the same; all preserve stuff is unnecessary)
-
- ; 0123456789012345 shift DnHei. >>1=offset
- ; 0..#########..... 5 5 2
- ; 1..#########..... 5 4 2
- ; 2.#########...... 6 3 1
- ; 3.#########...... 6 2 1
- ; 4#########....... 7 1 0
- ; 5#########....... 7 0 0
-
- ; numbers above aren't bit numbers but bitfield offsets
-
- ; (0,0) here is reference for x&y passed, just as the old DrawImage() way.
-
- MOVEQ #SQUAREY-1,DnHeight
-
- .yloop:
- MOVE.L DnHeight,DnScratch1
- LSR.L #1,DnScratch1
- BFEXTU (AnDPtr){DnScratch1:SQUAREX},DnData
- ADD.L DnX,DnScratch1
- BFINS DnData,(AnPPtr){DnScratch1:SQUAREX}
-
- ADDQ.L #2,AnDPtr
- ADDA.L DnBPR,AnPPtr
- DBF DnHeight,.yloop
-
- ENDC ; ISO
-
- ADDQ.W #1,DnPlane
- CMP.W #NPLANES,DnPlane
- BNE .planeloop
-
- MOVEM.L (sp)+,regstosave
-
- RTS
-